package com.ctr_flower.service.impl;

import com.ctr_flower.entity.TbCustomer;
import com.ctr_flower.dao.TbCustomerDao;
import com.ctr_flower.service.TbCustomerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TbCustomer)表服务实现类
 *
 * @author makejava
 * @since 2020-08-23 12:06:00
 */
@Service("tbCustomerService")
public class TbCustomerServiceImpl implements TbCustomerService {
    @Resource
    private TbCustomerDao tbCustomerDao;

    /**
     * 通过ID查询单条数据
     *
     * @param uuid 主键
     * @return 实例对象
     */
    @Override
    public TbCustomer queryById(Integer uuid) {
        return this.tbCustomerDao.queryById(uuid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<TbCustomer> queryAllByLimit(int offset, int limit) {
        return this.tbCustomerDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param tbCustomer 实例对象
     * @return 实例对象
     */
    @Override
    public TbCustomer insert(TbCustomer tbCustomer) {
        this.tbCustomerDao.insert(tbCustomer);
        return tbCustomer;
    }

    /**
     * 修改数据
     *
     * @param tbCustomer 实例对象
     * @return 实例对象
     */
    @Override
    public TbCustomer update(TbCustomer tbCustomer) {
        this.tbCustomerDao.update(tbCustomer);
        return this.queryById(tbCustomer.getUuid());
    }

    /**
     * 通过主键删除数据
     *
     * @param uuid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer uuid) {
        return this.tbCustomerDao.deleteById(uuid) > 0;
    }
}